10. Quiz: Bank Accounts 2 (7-4)

Directions:

Using the object from the previous quiz, answer the following quiz question:

var savingsAccount = {
  balance: 1000,
  interestRatePercent: 1,
  deposit: function addMoney(amount) {
    if (amount > 0) {
      savingsAccount.balance += amount;
    }
  },
  withdraw: function removeMoney(amount) {
    var verifyBalance = savingsAccount.balance - amount;
    if (amount > 0 && verifyBalance >= 0) {
      savingsAccount.balance -= amount;
    }
  }
};

Your Code:

Using Methods

Which of the following are valid ways to access properties and call methods from the savingsAccount object?

SOLUTION:
  • savingsAccount.balance;
  • savingsAccount["balance"];
  • savingsAccount.withdraw(50);

Have questions? Head to Knowledge for discussion with the Udacity Community.